package com.linhh.mall.center.web.controller;

import com.linhh.mall.center.api.StoreSeckillService;
import com.linhh.mall.center.common.pojo.StoreSeckill;
import com.linhh.mall.center.common.util.HttpResult;
import io.swagger.annotations.ApiOperation;
import org.apache.dubbo.config.annotation.Reference;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

/**
 * @Author linhh
 * @Date 2023 03 11 17 48
 **/
@RestController
@RequestMapping("api")
public class StoreSeckillController {

    @Reference
    private StoreSeckillService storeSeckillService;

    @ApiOperation(value = "列表")
    @GetMapping(value = "/getStoreSeckills")
    public HttpResult getStoreSeckills(Integer page,Integer size){
        Map<String,Object> map = storeSeckillService.queryAll(page+1,size);
        return HttpResult.success(map);
    }

    @PutMapping(value = "/storeSeckill")
    public HttpResult update(@Validated @RequestBody StoreSeckill storeSeckill){
        int result = storeSeckillService.saveOrUpdate(storeSeckill);
        return HttpResult.success(result);
    }
}
